import request from '@/utils/request'

const menuUrl = '/system/menu'

export function listSysMenu(data) {
  return request({
    url: `${menuUrl}/listSysMenu`,
    method: 'post',
    data: data
  })
}

export function saveSysMenu(data) {
  return request({
    url: `${menuUrl}/saveSysMenu`,
    method: 'post',
    data: data
  })
}

export function updateSysMenu(data) {
  return request({
    url: `${menuUrl}/updateSysMenu`,
    method: 'put',
    data: data
  })
}

export function deleteSysMenu(id) {
  return request({
    url: `${menuUrl}/deleteSysMenu/` + id,
    method: 'delete'
  })
}

export function listSysMenuToSelect(id) {
  return request({
    url: `${menuUrl}/listSysMenuToSelect/` + id,
    method: 'get'
  })
}

export function listSysMenuAllToSelect(id) {
  return request({
    url: `${menuUrl}/listSysMenuAllToSelect`,
    method: 'get'
  })
}

export function buildMenus() {
  return request({
    url: 'auth/getMenuByCurrentUser',
    method: 'get'
  })
}

export default {
  listSysMenu,
  saveSysMenu,
  updateSysMenu,
  deleteSysMenu,
  listSysMenuToSelect,
  listSysMenuAllToSelect
}
